/**
 * 
 */
package sqs.dataaccess.hibernate;

import java.util.List;

import org.hibernate.Query;

import sqs.dataaccess.UserDao;
import sqs.exception.DataAccessException;
import sqs.model.Questionnaire;
import sqs.model.User;

/**
 * @author kjleng
 *
 */
public class HibernateUserDao extends AbstractDao implements UserDao {

	public User getUserByUsername(String username) throws DataAccessException {
		try {
			User user = (User)super.find(User.class, username);
			return user;
		} catch (Throwable t) {
            throw new DataAccessException(t.toString());
        }
	}
	
	public List<User> getAllUsers() throws DataAccessException{
		try {
			List<User> users = (List<User>)super.findAll(User.class);
			return users;
		} catch (Throwable t) {
            throw new DataAccessException(t.toString());
        }
	}

	public void createUser(User user) throws DataAccessException {
		try {
			super.saveOrUpdate(user);
        } catch (Throwable t) {
            throw new DataAccessException(t.toString());
        }
	}

	public void updateUser(User user) throws DataAccessException {
		try {
			super.saveOrUpdate(user);
        } catch (Throwable t) {
            throw new DataAccessException(t.toString());
        }
	}

	public void removeUser(User user) throws DataAccessException{
		try {
			super.delete(user);
        } catch (Throwable t) {
            throw new DataAccessException(t.toString());
        }
	}
}
